﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Llibreria
{
    public partial class MantTemes : Form
    {
        DataTable dt;
        bool bl;
        int index;
        DataRow r;
        public MantTemes(DataTable dt)
        {
            this.dt = dt;
            this.bl = true;


            InitializeComponent();
        }
        public MantTemes(DataTable dt, int i)
        {
            this.dt = dt;
            this.bl = false;
            this.index = i;
            

            InitializeComponent();
            TxtTeme.Text = dt.Rows[i]["Tipus"].ToString();
        }


        private void MantTemes_Load(object sender, EventArgs e)
        {
            
        }

        private void BtnCancelaTeme_Click(object sender, EventArgs e)
        {
            Close();
        }

        private void BtnAceptarEditarTeme_Click(object sender, EventArgs e)
        {
            
        }
        private void BtnAceptarTeme_Click(object sender, EventArgs e)
        {
       
            if (bl == true)
            {
                r = dt.NewRow();
                r["Tipus"] = TxtTeme.Text;
                dt.Rows.Add(r);
            }
            else
            {   
                dt.Rows[index]["Tipus"] = TxtTeme.Text; 
            }
            Close();

        }

    
    }
}
